package com.example;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/2/16.
 */
public class Leetcode_1 {
    public int[] towSum(int[] num,int target){
        HashMap<Integer, Integer> map = new HashMap<Integer,Integer>();
        int[] result = new int[2];
        for(int i=0;i<num.length;i++){
            if(map.containsKey(target-num[i])){
                result[1]=map.get(target-num[i]);
                result[0]=i;
            }
            map.put(num[i],i);
        }
        return result;
    }

    public static void main(String[] args) {
        int[] num = new int[]{3,2,4};
        System.out.println(new Leetcode_1().towSum(num,6));
    }
}
